package com.taldh.design.patterns.proxy.dynamic;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**

     * 自定义回调类。

     */

    public class MethodInterceptorImpl implements MethodInterceptor {


        @Override
        public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {

            System.out.println("Before invoke " + method);

            Object result = proxy.invokeSuper(obj, args); // 原方法调用。

            System.out.println("After invoke" + method);

            return result;

        }

    }